﻿using AntdUI.Svg;
using CardRegisterCollection.Model;
using CardRegisterCollection.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace _9jCardRegisterCollection.Views
{
    public partial class ConfigurationSharePage : UserControl
    {
        public ConfigurationSharePage()
        {
            InitializeComponent();
        }


        private readonly string _sharePath = Environment.CurrentDirectory + @"\Temp\信息采集系统配置";

        private void butConfigurationShare_Click(object sender, EventArgs e)
        {
            ZipUtility.DeleteFolder(_sharePath);
            Directory.CreateDirectory(_sharePath);
    
            var orgDbPath = Environment.CurrentDirectory + @"\Db\main.mdb";
            if (File.Exists(orgDbPath))
            {
                File.Copy(orgDbPath, _sharePath + @"\main.mdb");
            }


            var dialog = new FolderBrowserDialog();
            dialog.Description = "请选择分享配置路径";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var savePath = dialog.SelectedPath;
                ZipUtility.Create(_sharePath, savePath+ @"\信息采集系统配置.zip", PubConstant.AppZipPassword);
                ZipUtility.DeleteFolder(_sharePath);
            }
        }
    }
}
